<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/7/20
 * Time: 15:07
 */

namespace Modules\Admin\Service;


class TemplateService
{
	//获取所有模板
	public function getTemplates(){
		//遍历templates目录
		$templates=glob(public_path ('templates/*'));
		$tp=[];
		foreach($templates as $v){
			$path=$v.'/package.json';
			if(is_file ($path)){
				$t=json_decode (file_get_contents ($path),true);
				$t['name']=basename($v);
				$t['preview']=asset ('templates/'.basename($v).'/preview.jpg');
				$tp[]=$t;
			}

		}
		return $tp;
	}
}